package cn.tedu.spring.bean;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

/**
 * Controller: 控制器层,接受请求返回响应;
 * Service: 业务层,处理业务逻辑；
 * Repository: 数据访问层,负责和数据库交互;
 * Component: 不分层,标识为普通的spring组件.
 */
//@Component
//@Service
//@Controller
@Repository
public class UserDao {
    /*
        @Value注解：属性值注入
          1.加载属性上;
          2.加载set方法上;
     */
    @Value("jdbc:mysql://localhost:3306/tedu")
    private String dbUrl;
    @Value("root")
    private String username;
    //@Value("root")
    private String password;

    @Value("qwertiop")
    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String toString() {
        return "UserDao{" +
                "dbUrl='" + dbUrl + '\'' +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                '}';
    }
}
